package com.fymxy.question_bank_management.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fymxy.question_bank_management.pojo.StudentExamnate;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

@Mapper
@Component
public interface StudentExamnateMapper {

    @Select("select distinct student.student_name,paper.paper_name,examnate.paper_no,examnate.student_no,teacher.teacher_no," +
            "teacher.teacher_name,score_record,answer_record,check_status from examnate,student,paper,teacher where examnate.paper_no = paper.paper_no " +
            "and examnate.student_no = student.student_no and teacher.teacher_no = paper.paper_setter_no")
    @Results(id = "ExamnateMap",value = {
            @Result(column = "student_name",property = "studentName"),
            @Result(column = "paper_name",property = "paperName"),
            @Result(column = "paper_no",property = "paperNo"),
            @Result(column = "student_no",property = "studentNo"),
            @Result(column = "score_record",property = "scoreRecord"),
            @Result(column = "answer_record",property = "answerRecord"),
            @Result(column = "check_status",property = "checkStatus")
    })
    IPage<StudentExamnate> selectAllExamnate(Page page);

    @Select("select distinct student.student_name,paper.paper_name,examnate.paper_no,examnate.student_no,teacher.teacher_no," +
            "teacher.teacher_name,score_record,answer_record,check_status from examnate,student,paper,teacher where examnate.paper_no = paper.paper_no " +
            "and examnate.student_no = student.student_no and teacher.teacher_no = paper.paper_setter_no and student.student_no = #{studentId}")
    @ResultMap(value = "ExamnateMap")
    IPage<StudentExamnate> selectExamnateByStudent(Page page,Integer studentId);

    @Select("select distinct student.student_name,paper.paper_name,examnate.paper_no,examnate.student_no,teacher.teacher_no," +
            "teacher.teacher_name,score_record,answer_record,check_status from examnate,student,paper,teacher where examnate.paper_no = paper.paper_no " +
            "and examnate.student_no = student.student_no and teacher.teacher_no = paper.paper_setter_no and teacher.teacher_no = #{teacherId}")
    @ResultMap(value = "ExamnateMap")
    IPage<StudentExamnate> selectExamnateByTeacher(Page page,Integer teacherId);
}
